package com.zbf.并发包;

import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;

/**
 * @author: LI-CI-GAO
 * 作者: licigao
 * 日期: 2021/8/16  16:01
 * 描述:
 */
public class MyCycThread extends Thread {

    private CyclicBarrier cyclicBarrier;

    private Long wait;

    public MyCycThread(CyclicBarrier cyclicBarrier,String name,Long wait) {
        super(name);
        this.cyclicBarrier = cyclicBarrier;
        this.wait=wait;
    }

    @Override
    public void run() {

        try {
            Thread.sleep(wait);

            System.out.println(Thread.currentThread().getName()+"==远动员到位==");

            cyclicBarrier.await();

            System.out.println(Thread.currentThread().getName()+"==远动员到位==起跑");
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (BrokenBarrierException e) {
            e.printStackTrace();
        }



    }
}
